#pragma once

#include "BeanieIncludes.h"
#include "BeanieEnums.h"
#include "FmodAudio.h"
#include "FmodChannel.h"
#include "FmodChannelGroup.h"
#include "FmodSoundGroup.h"
#include "List.h"
#include "Audio.h"

#define FM_ERROR(fmr) ((FMOD_RESULT)fmr>FMOD_OK)

//Fmod Framework
class FmodFramework
{
public:
	//attributes & members
	FMOD::System* m_system;
	FMOD_SPEAKERMODE m_mode;
	FMOD_CAPS m_caps;
	char m_name[256];
	unsigned int m_version;
	int m_numDrivers;
	List<FmodAudio*> m_audioList;
	List<FmodSoundGroup*>	m_groups;
	FMOD::SoundGroup*		m_MasterGroup;
	List<FmodChannel*>		m_channelList;
	List<FmodChannelGroup*>	m_channelGroups;
	FMOD::ChannelGroup*		m_MasterChannel;

	//ctor & dtor
	FmodFramework();
	~FmodFramework();

	//init functions
	int init();

	//release functions
	int release();

	//update functions
	int update();

	//load functions
	int loadAudio(
		char* a_source,
		void* a_audio,
		bool  a_stream);

	int addSoundGroup(char* name);

	int addToGroup(
		FmodAudio* a_audio,
		FmodSoundGroup* a_group);

	int createChannelGroup(
		char* name,
		int &a_gID);

	int addToChannelGroup(
		int a_cId,
		int a_gId);

	FmodChannelGroup* getChannelGroup(char* name, int len);

	//control functions
	int playAudio(int a_id);
	int playAudio(int a_id,int g_id);
};